#pragma once
#include "common.h"

class radixMap {
public:
	explicit radixMap() {
		size_t size = LEN * sizeof(void*);
		size_t align = alignSize::_align(size, 1 << PAGE_SHIFT);
		_arr = (void**)systemAlloc(align >> PAGE_SHIFT);
		memset(_arr, 0, size);
	}

	void set(PAGE_T id, void* s) {
		_arr[id] = s;
	}

	void* get(PAGE_T id) {
		if (id >> BITS) {
			return nullptr;
		}
		return _arr[id];
	}

private:
	const static size_t LEN = 1ull << BITS;
	void** _arr = 0;
};


class radixMap2 {
public:
	explicit radixMap2() {
		size_t size = LEN * sizeof(void*);
		size_t align = alignSize::align(size);
		size_t page = alignSize::index(align);
		_arr = (void**)systemAlloc(page);
		memset(_arr, 0, size);
	}

	void set(PAGE_T id, void* s) {
		_arr[id] = s;
	}

	void* get(PAGE_T id) {
		if (id >> BITS) {
			return nullptr;
		}
		return _arr[id];
	}

private:
	const static size_t LEN = 1ull << BITS;
	void** _arr = 0;
};

